<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
    <meta charset="utf-8">
    <title>恒铸智能柜管理平台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/resources/layui/css/layui.css"
          media="all" />
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/resources/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
</head>
<style>
    .layui-form-label {
        width: 32px !important;
    }

    .layui-input-block {
        margin-left: 66px !important;
    }

    .layui-form {
        padding: 10px 20px 0 0;
    }
</style>
<body class="childrenBody">
<form class="layui-form">
    <input type="hidden" title="id" class="ctId" value="${requestScope.id}">
    <input type="hidden" title="typeId" class="typeId" value="${requestScope.typeId}">
    <div class="layui-form-item">
        <label class="layui-form-label">时长</label>
        <div class="layui-input-block">
            <input type="text" name="theLenght" placeholder="请输入时长(分钟)"
                   autocomplete="off" class="layui-input title" value="${requestScope.data.theLenght}">

        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block">
				<input placeholder="请输入价格(元)" name="thePrice"
                          class="layui-input content" value="${requestScope.data.thePrice}"></input>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" style="float: right;" type="submit">立即提交</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;


        $("form").submit(function(e){
            var id = $(".ctId").val();
            var typeId = $(".typeId").val();
            var param = $("form").serialize() + "&id="+id+"&typeId="+typeId; // +"&sign=1"
            console.log(param);
            // console.log(param)
            var title = $(".title").val();
            var content = $(".content").val();


            if(title != "" && content != ""){

                $.ajax({
                    type: "POST",
                    url: "/caseType/retain",
                    async: false,
                    data: param,
                    success: function (res) {
                        if (res.success) {
                            layer.msg(res.message)
                            parent.window.location.reload();
                        } else {
                            layer.msg(res.message)
                        }
                    },
                    error: function (err) {

                    }
                })

                // $.post("/caseType/retain", param, function (res) {
                //     if (res.success) {
                //         layer.msg(res.message)
                //         parent.window.location.reload();
                //     } else {
                //         layer.msg(res.message)
                //     }
                // })
            }else{
                layer.msg("不能为空！")
            }
        });

    });

</script>
</body>
</html>